<?php
/**
 * 分析
 */
namespace app\sports\match\service;

use app\sports\match\model\MatchModel;

class AnalysisService
{
    /**
     * 获取分析数据
     */
    public function getAnalysisByMatchId($matchId)
    {
        //获取比赛信息
        $battleService = new BattleService();
        $commonInfo = $battleService->getBattleInfo($matchId);

        $matchModel = new MatchModel();
        $info = $matchModel->getAnalysisByMatchId($matchId);
        if (empty($info)) {
            return [];
        }
        //伤停情况
        $injury = json_decode($info['injury'], true);

        //联赛积分
        $integral = [];

        //历史交锋
        $history = [];
        //近期战绩
        $recent = [];

        return [
            'match_common' => $commonInfo,
            'injury' => $injury,
            'integral' => $integral,
            'history' => $history,
            'recent' => $recent
        ];
    }
}